using System;
using System.Collections.Generic;


namespace Gfw.Models.Admin
{
	[Serializable]
	public partial class UsrRoles: IEquatable<UsrRoles>
	{

		#region Private Members

		private string _id; 
		private IList<UsrUserrole> _UsrUserroleList; 
		private string _code; 
		private string _name; 
		private string _description; 
		private int _sortindex; 		
		#endregion

		#region Constructor

		public UsrRoles()
		{
			_id = String.Empty; 
			_UsrUserroleList = new List<UsrUserrole>(); 
			_code = String.Empty; 
			_name = String.Empty; 
			_description = String.Empty; 
			_sortindex = 0; 
		}
		#endregion // End of Default ( Empty ) Class Constuctor

		#region Required Fields Only Constructor
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public UsrRoles(
			string id)
			: this()
		{
			_id = id;
			_code = String.Empty;
			_name = String.Empty;
			_description = String.Empty;
			_sortindex = 0;
		}
		#endregion // End Constructor

		#region Public Properties
			
		public virtual string Id
		{
			get
			{ 
				return _id;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for Id", value, "null");
				
				if(  value.Length > 40)
					throw new ArgumentOutOfRangeException("Invalid value for Id", value, value.ToString());
				
				_id = value;
			}
		}
			
		public virtual IList<UsrUserrole> UsrUserroleList
		{
			get
			{
				return _UsrUserroleList;
			}
			set
			{
				_UsrUserroleList = value;
			}
		}

		public virtual string Code
		{
			get
			{ 
				return _code;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for Code", value, value.ToString());
				
				_code = value;
			}
		}
			
		public virtual string Name
		{
			get
			{ 
				return _name;
			}

			set	
			{	
				if(  value != null &&  value.Length > 256)
					throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
				
				_name = value;
			}
		}
			
		public virtual string Description
		{
			get
			{ 
				return _description;
			}

			set	
			{	
				if(  value != null &&  value.Length > 256)
					throw new ArgumentOutOfRangeException("Invalid value for Description", value, value.ToString());
				
				_description = value;
			}
		}
			
		public virtual int SortIndex
		{
			get
			{ 
				return _sortindex;
			}
			set
			{
				_sortindex = value;
			}

		}
			
				
		#endregion 

		#region Public Functions

		public virtual void AddUsrUserrole(UsrUserrole obj)
		{
			#region Check if null
			if (obj == null)
				throw new ArgumentNullException("obj", "El parametro no puede ser nulo");
			#endregion
			_UsrUserroleList.Add(obj);
		}
		

		#endregion //Public Functions

		#region Equals And HashCode Overrides
		/// <summary>
		/// local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
			UsrRoles castObj = (UsrRoles)obj; 
			return ( castObj != null ) &&
				( this._id == castObj.Id );
		}
		
		/// <summary>
		/// local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{
			
			int hash = 57; 
			hash = 27 ^ hash ^ _id.GetHashCode();
			return hash; 
		}
		#endregion
		
		#region IEquatable members

		public virtual bool Equals(UsrRoles other)
		{
			if (other == this)
				return true;
		
			return ( other != null ) &&
				( this._id == other.Id );
				   
		}

		#endregion
		
	}
}
